package com.turnengine.client.local.message.bean;

import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import java.io.IOException;

/**
 * The Local Message Content Serializer.
 */
public class LocalMessageContentSerializer implements ILocalMessageContentSerializer {

	@Override
	public ILocalMessageContent readObject(IDataReader reader) throws IOException {

		// Read fields
		int id = reader.readInt();
		String content = reader.readString(true);

		// Create object
		ILocalMessageContent object = new LocalMessageContent();
		object.setId(id);
		object.setContent(content);
		return object;
	}

	public void writeObject(IDataWriter writer, ILocalMessageContent object) throws IOException {

		// Get fields
		int id = object.getId();
		String content = object.getContent();

		// Write fields
		writer.writeInt(id);
		writer.writeString(content, true);
	}
}
